-
Notifications
You must be signed in to change notification settings - Fork 322
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: send one sample event, response per label set in the configured duration #5298
Conversation
…he configured duration
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #5298 +/- ##
==========================================
- Coverage 74.78% 74.76% -0.02%
==========================================
Files 433 437 +4
Lines 60979 61211 +232
==========================================
+ Hits 45601 45764 +163
- Misses 12848 12918 +70
+ Partials 2530 2529 -1 ☔ View full report in Codecov by Sentry. |
…into feature/obs-415-support-aggregation-time-as-a-configuration-on-rudder-server
…s/rudder-server into feature/obs-415-support-aggregation-time-as-a-configuration-on-rudder-server
…tion-on-rudder-server' of https://github.com/rudderlabs/rudder-server into feature/obs-415-support-aggregation-time-as-a-configuration-on-rudder-server
…tion-on-rudder-server' into feat.event-sampling-badger
This reverts commit c3d0db9.
…tion-on-rudder-server' into feat.event-sampling-badger
case InMemoryCacheTypeEventSampler: | ||
es, err = NewInMemoryCacheEventSampler(ttl, eventSamplingCardinality) | ||
default: | ||
err = fmt.Errorf("invalid event sampler type: %s", eventSamplerType.Load()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably default to either of the above types and leave a log instead of panicking
func NewEventSampler( | ||
ttl config.ValueLoader[time.Duration], | ||
eventSamplerType config.ValueLoader[string], | ||
eventSamplingCardinality config.ValueLoader[int], | ||
conf *config.Config, | ||
log logger.Logger, | ||
) (EventSampler, error) { | ||
var es EventSampler | ||
var err error | ||
|
||
switch eventSamplerType.Load() { | ||
case BadgerTypeEventSampler: | ||
es, err = NewBadgerEventSampler(BadgerEventSamplerPathName, ttl, conf, log) | ||
case InMemoryCacheTypeEventSampler: | ||
es, err = NewInMemoryCacheEventSampler(ttl, eventSamplingCardinality) | ||
default: | ||
err = fmt.Errorf("invalid event sampler type: %s", eventSamplerType.Load()) | ||
} | ||
|
||
if err != nil { | ||
return nil, err | ||
} | ||
return es, nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func NewEventSampler( | |
ttl config.ValueLoader[time.Duration], | |
eventSamplerType config.ValueLoader[string], | |
eventSamplingCardinality config.ValueLoader[int], | |
conf *config.Config, | |
log logger.Logger, | |
) (EventSampler, error) { | |
var es EventSampler | |
var err error | |
switch eventSamplerType.Load() { | |
case BadgerTypeEventSampler: | |
es, err = NewBadgerEventSampler(BadgerEventSamplerPathName, ttl, conf, log) | |
case InMemoryCacheTypeEventSampler: | |
es, err = NewInMemoryCacheEventSampler(ttl, eventSamplingCardinality) | |
default: | |
err = fmt.Errorf("invalid event sampler type: %s", eventSamplerType.Load()) | |
} | |
if err != nil { | |
return nil, err | |
} | |
return es, nil | |
} | |
func NewEventSampler( | |
ttl config.ValueLoader[time.Duration], | |
eventSamplerType config.ValueLoader[string], | |
eventSamplingCardinality config.ValueLoader[int], | |
conf *config.Config, | |
log logger.Logger, | |
) (es EventSampler, err error) { | |
switch eventSamplerType.Load() { | |
case BadgerTypeEventSampler: | |
es, err = NewBadgerEventSampler(BadgerEventSamplerPathName, ttl, conf, log) | |
case InMemoryCacheTypeEventSampler: | |
es, err = NewInMemoryCacheEventSampler(ttl, eventSamplingCardinality) | |
default: | |
err = fmt.Errorf("invalid event sampler type: %s", eventSamplerType.Load()) | |
} | |
return | |
} |
|
||
type InMemoryCacheEventSampler struct { | ||
cache *cachettl.Cache[string, bool] | ||
mu sync.Mutex |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can get rid of the mu from what I can see.. cachettl already takes care of the safety
@@ -0,0 +1,153 @@ | |||
package event_sampler |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add tests for both badger samples and in memory samplers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these are present in event_sampler_test.go
enterprise/reporting/reporting.go
Outdated
|
||
if eventSamplingEnabled.Load() { | ||
var err error | ||
eventSampler, err = event_sampler.NewEventSampler(eventSamplingDuration, eventSamplerType, eventSamplingCardinality, conf, log) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pass ctx
into this function and propagate it across
return nil, err | ||
} | ||
|
||
go es.gcLoop() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use rruntime.Go
instead of go
}) | ||
} | ||
|
||
func (es *BadgerEventSampler) performGC() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use the same logic we have for dedup and live events
Description
Send one sample event or response per LabelSet to reporting within the configured duration.
Linear Ticket
Completes OBS-461
Security